<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/

if(isset($_SESSION['u_nic'])&&isset($_GET['id'])) {
	$title = "Gestion d'un domaine";
	$tplinc = "panel-domaine";
	$tpl->assign(array(
		'iconesleft' => 3,
		'prod' => '1',
		'prod_id' => intval($_GET['id'])
	));
	include ROOT.'php/lib/panel_inc.php';
	$dom_current = intval($_GET['id']);
	$infos_dom = mysql_query("SELECT 	comptes_domain.u_nic,
										comptes_domain.id AS domain_id,
										comptes_domain.domaine,
										UNIX_TIMESTAMP(comptes_domain.create),
										UNIX_TIMESTAMP(comptes_domain.expire),
										comptes_domain.dns1,
										comptes_domain.dns2, 
										comptes_domain.dns3, 
										comptes_domain.dns4,
										comptes_domain.authinfo,
										comptes_domain.create,
										comptes_domain.expire,
										comptes_domain.locked,
										comptes_domain.zone_dns,
										comptes_domain.etat,
										comptes_domain.id_registrar
										FROM comptes_domain 
										WHERE comptes_domain.id='".$dom_current."' AND comptes_domain.u_nic='".$_SESSION['u_nic']."'");
	if(mysql_num_rows($infos_dom) == 1) {
		$infos_dom = mysql_fetch_array($infos_dom);
		$parse = 1;
		if((($infos_dom['etat'] == 1) OR ($infos_dom['etat'] == 7)) AND $infos_dom['expire'] == "0000-00-00 00:00:00") {
			include ROOT.'php/lib/registrars/'.$registrar[$infos_dom['id_registrar']].'.inc.php';
			$_domgest = new bh_doms_gest();
			$dom_info = $_domgest->dom_infos($infos_dom['domaine']);	
			query("UPDATE comptes_domain SET `create` = '".$dom_info['create']."', `expire` = '".$dom_info['expire']."', authinfo = '".$dom_info['authinfo']."' WHERE domaine = '".$infos_dom['domaine']."'");
		}
		else {
			$dom_info = $infos_dom;
		}
		$lie = mysql_fetch_array(query("SELECT COUNT(*) AS lie FROM hebergdata_doms WHERE id_dom_bh ='".$dom_current."'"));
			$extension = explode('.',$infos_dom['domaine']);
			if($lie['lie'] == 1) {
				$tpl->assign(array(
				"load" => "new Effect.Pulsate(document.getElementById('lie'))"
				));
			}
		$tpl->assign(array(
				"current_dom" => $infos_dom['domaine'],
				"dom_id" => $infos_dom['domain_id'],
				"heberg_id" => $infos_dom['heberg_id'],
				"create" => $dom_info['create'],
				"expire" => $dom_info['expire'],
				"dns1" => $dom_info['dns1'],
				"dns2" => $dom_info['dns2'],
				"dns3" => $dom_info['dns3'],
				"dns4" => $dom_info['dns4'],
				"etat" => $infos_dom['etat'],
				"cle" => $dom_info['authinfo'],
				"locked" => $infos_dom['locked'],
				"zone_dns" => $infos_dom['zone_dns'],
				"user_linux" => $infos_dom['user_linux'],
				"lie" => $lie['lie'],
				"ext" => $extension[1]
			));

		}
}

?>